\doxysection{x\+Queue\+Create\+Static }
\hypertarget{group__x_queue_create_static}{}\label{group__x_queue_create_static}\index{xQueueCreateStatic@{xQueueCreateStatic}}
queue. h 
\begin{DoxyPre}
QueueHandle\_t xQueueCreateStatic(                           UBaseType\_t uxQueueLength,                           UBaseType\_t uxItemSize,                           uint8\_t *pucQueueStorageBuffer,                           StaticQueue\_t *pxQueueBuffer                       );
  \end{DoxyPre}


Creates a new queue instance, and returns a handle by which the new queue can be referenced.

Internally, within the Free\+RTOS implementation, queues use two blocks of memory. The first block is used to hold the queue\textquotesingle{}s data structures. The second block is used to hold items placed into the queue. If a queue is created using x\+Queue\+Create() then both blocks of memory are automatically dynamically allocated inside the x\+Queue\+Create() function. (see \href{http://www.freertos.org/a00111.html}{\texttt{http\+://www.\+freertos.\+org/a00111.\+html}}). If a queue is created using x\+Queue\+Create\+Static() then the application writer must provide the memory that will get used by the queue. x\+Queue\+Create\+Static() therefore allows a queue to be created without using any dynamic memory allocation.

\href{http://www.FreeRTOS.org/Embedded-RTOS-Queues.html}{\texttt{http\+://www.\+Free\+RTOS.\+org/\+Embedded-\/\+RTOS-\/\+Queues.\+html}}


\begin{DoxyParams}{Parameters}
{\em ux\+Queue\+Length} & The maximum number of items that the queue can contain.\\
\hline
{\em ux\+Item\+Size} & The number of bytes each item in the queue will require. Items are queued by copy, not by reference, so this is the number of bytes that will be copied for each posted item. Each item on the queue must be the same size.\\
\hline
{\em puc\+Queue\+Storage\+Buffer} & If ux\+Item\+Size is not zero then puc\+Queue\+Storage\+Buffer must point to a uint8\+\_\+t array that is at least large enough to hold the maximum number of items that can be in the queue at any one time -\/ which is ( ux\+Queue\+Length \texorpdfstring{$\ast$}{*} ux\+Items\+Size ) bytes. If ux\+Item\+Size is zero then puc\+Queue\+Storage\+Buffer can be NULL.\\
\hline
{\em px\+Queue\+Buffer} & Must point to a variable of type Static\+Queue\+\_\+t, which will be used to hold the queue\textquotesingle{}s data structure.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
If the queue is created then a handle to the created queue is returned. If px\+Queue\+Buffer is NULL then NULL is returned.
\end{DoxyReturn}
Example usage\+: 
\begin{DoxyPre}
struct AMessage
\{
   char ucMessageID;
   char ucData[ 20 ];
\};

\#define QUEUE\_LENGTH 10
\#define ITEM\_SIZE sizeof( uint32\_t )

// xQueueBuffer will hold the queue structure.
StaticQueue\_t xQueueBuffer;

// ucQueueStorage will hold the items posted to the queue.  Must be at least
// [(queue length) * ( queue item size)] bytes long.
uint8\_t ucQueueStorage[ QUEUE\_LENGTH * ITEM\_SIZE ];

void vATask( void *pvParameters )
\{
QueueHandle\_t xQueue1;

   // Create a queue capable of containing 10 uint32\_t values.
   xQueue1 = xQueueCreate( QUEUE\_LENGTH, // The number of items the queue can hold.
                        ITEM\_SIZE     // The size of each item in the queue
                        \&( ucQueueStorage[ 0 ] ), // The buffer that will hold the items in the queue.
                        \&xQueueBuffer ); // The buffer that will hold the queue structure.

   // The queue is guaranteed to be created successfully as no dynamic memory
   // allocation is used.  Therefore xQueue1 is now a handle to a valid queue.

   // ... Rest of task code.
\}
\end{DoxyPre}
 